<template>
	<view>
		<tanchu :show="show" @change="change" :custom="true" :mask-click="false">
			<view class="nicheng_content">
				<view class="thirty font_bold heise_ziti text_center">{{text}}</view>
				<view class="nicheng_content_input ">
					<input v-if="zhaungtai!=2" :placeholder="'请输入'+placeholder_input" class="input_inpit"
						v-model="remarks" placeholder-style="color:#999;" :maxlength="zhaungtai==6?6:140"/>
					<view v-else class="two_four shenhui_ziti">确定要清空与TA的聊天记录吗？</view>
				</view>
				<view class="nicheng_footer">
					<view class="qianhui_ziti" @click="cancel('tip',1)">取消</view>
					<view style="color: #F8CF00;" @click="cancel('tip',2,remarks)">确定</view>
				</view>
			</view>
		</tanchu>
	</view>
</template>

<script>
	// import { base64ToPath, pathToBase64  } from '@/configure/image-tools.js';
	export default {
		data() {
			return {
				type: '',
				text: '',
				placeholder_input: ''
			}
		},
		props: {
			show: {
				type: Boolean,
				default: false
			},
			zhaungtai: {
				type: Number,
				default: -1
			},
			remarks: {
				type: String,
				default: ""
			}
		},
		onLoad() {},
		watch: {
			show(newValue) {
				if (newValue == true) {
					this.togglePopup('center', 'tip');
				}
			},
			zhaungtai(newValue) {
				//1备注   2删除   3 修改群昵称
				if (newValue != -1) {
					console.log(newValue)
					if (newValue == 6) {
						console.log('newValue')
						console.log(newValue)
						this.text = "修改昵称"
						this.placeholder_input = '昵称'
					}
					if (newValue == 1) {
						this.text = "修改备注"
						this.placeholder_input = '备注名称'
					} else if (newValue == 2) {
						this.text = "确认清空聊天记录"
					} else if (newValue == 3) {
						this.text = "修改群昵称"
						this.placeholder_input = '群昵称'
					} else if (newValue == 4) {
						this.text = "添加分组"
						this.placeholder_input = '分组名称'
					} else if (newValue == 5) {
						this.text = "修改群介绍"
						this.placeholder_input = '群介绍'
					}
				}
			},
		},
		mounted() {
			// this.haibao();
		},
		methods: {
			change(e) {},
			togglePopup(type, open) {
				switch (type) {
					case 'top':
						break

					case 'bottom':
						break
					case 'center':
						break
				}
				// this.type = type 
				if (open === 'tip') {
					// this.show = true
				} else {
					this.$refs[open].open()
				}
			},

			cancel(type, state, remarks) {
				if (state == 2) {
					var patt1 = new RegExp(/\s+/g); //正则验证空格
					if (remarks == '') {
						uni.showToast({
							title: '请输入' + this.placeholder_input,
							icon: "none"
						});
						return false;
					}

					if (patt1.test(remarks)) {
						uni.showToast({
							title: this.placeholder_input + '格式不正确',
							icon: "none"
						});
						return false;
					}
				}
				if (type === 'tip') {
					// this.show = false
					this.$emit('tanchuangbi', {
						state: state,
						remarks: remarks
					})

				} else {
					// this.$emit('tanchuangbi',{state:state,remarks:remarks})
				}
				// this.$refs[type].close()
			},
		}
	}
</script>

<style lang="scss">
	.nicheng_content {
		width: calc(63.7% - 60rpx);
		overflow: hidden;
		margin: 0 auto;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		padding: 40rpx 48rpx 0rpx;
	}

	.nicheng_content_input {
		// width: 80%;
		overflow: hidden;
		margin: 20rpx auto;
	}

	.nicheng_content_input input {
		// width: calc(100% - 52rpx);
		padding: 4rpx 0;
		height: 60rpx;
		text-align: center;
		font-size: 20rpx;
		border: none;
		color: #666;
	}

	.nicheng_footer {
		width: 100%;
		overflow: hidden;
		// border-top: 2rpx solid #F5F5F5;
	}

	.nicheng_footer view {
		width: calc(50% - 1rpx);
		overflow: hidden;
		float: left;
		text-align: center;
		font-size: 28rpx;
		padding: 20rpx 0rpx 30rpx;
	}
</style>
